package com.scsj.supermarket.presenter;

import android.content.Context;
import android.util.Log;

import com.scsj.supermarket.base.LoginBase;
import com.scsj.supermarket.base.ShopCheckInBase;
import com.scsj.supermarket.bean.LoginBean;
import com.scsj.supermarket.bean.ShopCheckInCommitBean;
import com.scsj.supermarket.model.LoginModel;
import com.scsj.supermarket.model.ShopCheckInModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 基础presenter 实现示例
 */

public class ShopCheckInPresenter extends BasePresenter implements ShopCheckInBase.IPresenter {

    private ShopCheckInBase.IModel mModel;
    private ShopCheckInBase.IView mView;

    public ShopCheckInPresenter(ShopCheckInBase.IView view) {
        mView = view;
        mModel = new ShopCheckInModel();
    }

    @Override
    public void deliverData(final Context context, RequestBody requestBody) {

        addSubscription(mModel.getData(requestBody, new ResponseCallback<ShopCheckInCommitBean>() {
            @Override
            public void onSuccess(ShopCheckInCommitBean result) {

                if (result.getStatusCode() == 200 ) {

                    mView.showSuccessMsg("登录成功",result);

                } else {
                    mView.showErrorMsg(result.getMsg());
                }

            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("onFaild", msg + "");
            }
        }));
    }


}
